﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BTKERP.DAL;
using BTKERP.Model;
using BTKERP.Model.Web;

namespace BTKERP.BLL.Inventory
{
     public class InventoryInfoMgt
    {
         private static readonly CategoryDAL categoryDAL = DataContextHelper.GetDbContect<CategoryDAL>();
         private static readonly CityDAL cityDAL = DataContextHelper.GetDbContect<CityDAL>();
         private static readonly CompanyDAL companyDAL = DataContextHelper.GetDbContect<CompanyDAL>();
         private static readonly CountryDAL coutryDAL = DataContextHelper.GetDbContect<CountryDAL>();
         private static readonly OutletDAL outletDAL = DataContextHelper.GetDbContect<OutletDAL>();
         private static readonly ProductDAL productDAL = DataContextHelper.GetDbContect<ProductDAL>();
         private static readonly ProductRecipeUnitDAL productRecipeUnitDAL = DataContextHelper.GetDbContect<ProductRecipeUnitDAL>();
         private static readonly ShelfDAL shelfDAL = DataContextHelper.GetDbContect<ShelfDAL>();
         private static readonly UnitDAL unitDAL = DataContextHelper.GetDbContect<UnitDAL>();
         private static readonly UnitTypeDAL unitTypeDAL = DataContextHelper.GetDbContect<UnitTypeDAL>();
         private static readonly WarehouseDAL warehouseDAL = DataContextHelper.GetDbContect<WarehouseDAL>();
         private static readonly WarehouseAreaDAL warehouseAreaDAL = DataContextHelper.GetDbContect<WarehouseAreaDAL>();
         private static readonly WarehouseStockDAL stockDAL = DataContextHelper.GetDbContect<WarehouseStockDAL>();
         private static readonly SupplierDAL supplierDAL = DataContextHelper.GetDbContect<SupplierDAL>();

         #region Category Info Management
         public static List<Category> GetCategories()
         {
             return categoryDAL.GetAll();
         }

         public static Category GetCategoryById(Guid id)
         {
             return categoryDAL.GetById(id);
         }

         public static Category AddCategory(string paramName, string paramDescription, string paramCreatedBy)
         {
             return categoryDAL.Add(paramName, paramDescription, paramCreatedBy);
         }

         public static bool DeleteCategory(Guid id)
         {
             return categoryDAL.DeleteById(id);
         }

         public static Category UpdateCategory(Guid paramId, string paramName, string paramDescription, string paramUpdatedBy)
         {
             return categoryDAL.UpdateById(paramId, paramName, paramDescription, paramUpdatedBy);
         }
         #endregion

         #region City Info Management
         public static List<City> GetCities()
         {
             return cityDAL.GetAll();
         }

         public static City GetCityById(Guid id)
         {
             return cityDAL.GetById(id);
         }

         public static City AddCity(string paramName, string paramDescription, int paramCountryId, string paramCreatedBy)
         {
             return cityDAL.Add(paramName, paramDescription, paramCountryId, paramCreatedBy);
         }

         public static bool DeleteCity(Guid id)
         {
             return cityDAL.DeleteById(id);
         }

         public static City UpdateCity(Guid paramId, string paramName, string paramDescription, int paramCountryId, string paramUpdatedBy)
         {
             return cityDAL.UpdateById(paramId, paramName, paramDescription, paramCountryId, paramUpdatedBy);
         }
         #endregion

         #region Company Info Management
         public static List<Company> GetCompanies()
         {
             return companyDAL.GetAll();
         }

         public static Company GetCompanyById(Guid id)
         {
             return companyDAL.GetById(id);
         }

         public static Company AddCompany(string paramName, string paramDescription, int paramCentralWarehouseId, string paramAddress1,
                                   string paramAddress2, string paramAddress3, string paramPostCode, int paramCountryId, int paramCityId,
                                  string paramTel, string paramFax, string paramWebsite, string paramEmail, string paramCompanyRegisterationNo,
                                  string paramGSTNo, string paramSoftwareLisence, DateTime paramSoftwareStartDate, DateTime paramSoftwareExpiryDate,
                                  string paramLogoPath)
         {
             return companyDAL.Add(paramName,  paramDescription, paramCentralWarehouseId, paramAddress1,
                                   paramAddress2, paramAddress3, paramPostCode,  paramCountryId,  paramCityId,
                                   paramTel,  paramFax,  paramWebsite,  paramEmail,  paramCompanyRegisterationNo,
                                   paramGSTNo,  paramSoftwareLisence,  paramSoftwareStartDate,  paramSoftwareExpiryDate,
                                   paramLogoPath);
         }

         public static bool DeleteCompany(Guid id)
         {
             return companyDAL.DeleteById(id);
         }

         public static Company UpdateCity(Guid paramId, string paramName, string paramDescription, int paramCentralWarehouseId, string paramAddress1,
                                   string paramAddress2, string paramAddress3, string paramPostCode, int paramCountryId, int paramCityId,
                                  string paramTel, string paramFax, string paramWebsite, string paramEmail, string paramCompanyRegisterationNo,
                                  string paramGSTNo, string paramSoftwareLisence, DateTime paramSoftwareStartDate, DateTime paramSoftwareExpiryDate,
                                  string paramLogoPath)
         {
             return companyDAL.UpdateById(paramId, paramName, paramDescription, paramCentralWarehouseId, paramAddress1,
                                    paramAddress2, paramAddress3, paramPostCode, paramCountryId, paramCityId,
                                    paramTel, paramFax, paramWebsite, paramEmail, paramCompanyRegisterationNo,
                                    paramGSTNo, paramSoftwareLisence, paramSoftwareStartDate, paramSoftwareExpiryDate,
                                   paramLogoPath);
         }
         #endregion

         #region Country Info Management
         public static List<Country> GetCoutires()
         {
             return coutryDAL.GetAll();
         }

         public static Country GetCountryById(Guid id)
         {
             return coutryDAL.GetById(id);
         }

         public static Country AddCountry(string paramName, string paramDescription, string paramCountryCode, string paramLanguage, string paramCreatedBy)
         {
             return coutryDAL.Add(paramName, paramDescription, paramCountryCode, paramLanguage, paramCreatedBy);
         }

         public static bool DeleteCountry(Guid id)
         {
             return coutryDAL.DeleteById(id);
         }

         public static Country UpdateCountry(Guid paramId, string paramName, string paramDescription, string paramCountryCode, string paramLanguage, string paramUpdatedBy)
         {
             return coutryDAL.UpdateById(paramId, paramName, paramDescription, paramCountryCode, paramLanguage, paramUpdatedBy);
         }
         #endregion

         #region Outlet Info Management
         public static List<Outlet> GetOutlets()
         {
             return outletDAL.GetAll();
         }

         public Outlet GetOutletById(Guid id)
         {
             return outletDAL.GetById(id);
         }

         public static Outlet AddOutlet(string paramName, string paramDescription, int paramWarehouseId, string paramAddress1,
                                 string paramAddress2, string paramAddress3, string paramFax, string paramTel, string paramPostCode,
                                 int paramCountryId, int paramCityId, int paramManager, string paramPOSLocationCode, string paramCreatedBy)
         {
             return outletDAL.Add(paramName, paramDescription, paramWarehouseId, paramAddress1,
                                 paramAddress2, paramAddress3,  paramFax,  paramTel,  paramPostCode,
                                  paramCountryId,  paramCityId,  paramManager,  paramPOSLocationCode,  paramCreatedBy);
         }

         public static bool DeleteOutlet(Guid id)
         {
             return outletDAL.DeleteById(id);
         }

         public static Outlet UpdateOutlet(Guid paramId, string paramName, string paramDescription, int paramWarehouseId, string paramAddress1,
                                 string paramAddress2, string paramAddress3, string paramFax, string paramTel, string paramPostCode,
                                 int paramCountryId, int paramCityId, int paramManager, string paramPOSLocationCode, string paramUpdatedBy)
         {
             return outletDAL.UpdateById(paramId, paramName, paramDescription, paramWarehouseId, paramAddress1,
                                  paramAddress2,  paramAddress3,  paramFax,  paramTel,  paramPostCode,
                                  paramCountryId, paramCityId,  paramManager, paramPOSLocationCode, paramUpdatedBy);
         }
         #endregion

         #region Product Info Management
         public static List<Product> GetProducts()
         {
             return productDAL.GetAll();
         }

         public static Product GetProductById(Guid id)
         {
             return productDAL.GetById(id);
         }

         public static Product AddProduct(string paramCode, string paramName, string paramPhysicalBarcode, string paramPackBarcode,
                                  string paramDescription, Guid paramCategoryId, Guid paramPhysicalUnitId, Guid paramPackUnitId, decimal paramNumberPerPhysical,
                                  decimal paramPhysicalSalePrice, decimal paramPackSalePrice, string paramCreatedBy, int paramStatus)
         {
             return productDAL.Add(paramCode,  paramName,  paramPhysicalBarcode,  paramPackBarcode,
                                   paramDescription,  paramCategoryId,  paramPhysicalUnitId,  paramPackUnitId,  paramNumberPerPhysical,
                                   paramPhysicalSalePrice,  paramPackSalePrice,  paramCreatedBy,  paramStatus);
         }

         public static bool DeleteProduct(Guid id)
         {
             return productDAL.DeleteById(id);
         }

         public static Product UpdateProduct(Guid paramId, string paramCode, string paramName, string paramPhysicalBarcode, string paramPackBarcode,
                                  string paramDescription, Guid paramCategoryId, Guid paramPhysicalUnitId, Guid paramPackUnitId, decimal paramNumberPerPhysical,
                                  decimal paramPhysicalSalePrice, decimal paramPackSalePrice, string paramUpdatedBy, int paramStatus)
         {
             return productDAL.UpdateById(paramId,  paramCode,  paramName,  paramPhysicalBarcode,  paramPackBarcode,
                                   paramDescription,  paramCategoryId,  paramPhysicalUnitId,  paramPackUnitId,  paramNumberPerPhysical,
                                   paramPhysicalSalePrice,  paramPackSalePrice,  paramUpdatedBy,  paramStatus);
         }
         #endregion

         #region ProductRecipeUnit Info Management
         public static List<ProductRecipeUnit> GetProductRecipeUnits()
         {
             return productRecipeUnitDAL.GetAll();
         }

         public static List<ProductRecipeUnit> GetProductRecipeUnitByProductId(Guid productId)
         {
             return productRecipeUnitDAL.GetByProductId(productId);
         }

         public static ProductRecipeUnit AddProductRecipeUnit(Guid paramProductId, Guid paramUnitId, decimal paramNumberPerPackUnit, decimal paramShrinkage, string paramCreatedBy)
         {
             return productRecipeUnitDAL.Add(paramProductId, paramUnitId, paramNumberPerPackUnit, paramShrinkage, paramCreatedBy);
         }

         public static bool DeleteProductRecipeUnit(Guid productId, Guid unitId)
         {
             return productRecipeUnitDAL.DeleteById(productId, unitId);
         }

         public static ProductRecipeUnit UpdateproductRecipeUnitDAL(Guid paramProductId, Guid paramUnitId, decimal paramNumberPerPackUnit, decimal paramShrinkage, string paramUpdatedBy)
         {
             return productRecipeUnitDAL.UpdateById(paramProductId, paramUnitId, paramNumberPerPackUnit, paramShrinkage, paramUpdatedBy);
         }
         #endregion

         #region Shelf Info Management
         public static List<Shelf> GetShelves()
         {
             return shelfDAL.GetAll();
         }

         public static Shelf GetShelfById(Guid id)
         {
             return shelfDAL.GetById(id);
         }

         public static Shelf AddShelf(string paramCode, string paramBarcode, string paramName, string paramDescription, Guid paramWarehouseId,
                                int paramLevels, decimal paramCapacity, decimal paramWeight, decimal paramLength,
                                decimal paramWidth, decimal paramHeight, decimal paramThickness, string paramCreatedBy)
         {
             return shelfDAL.Add(paramCode, paramBarcode, paramName,  paramDescription,  paramWarehouseId,
                                 paramLevels,  paramCapacity,  paramWeight,  paramLength,
                                 paramWidth,  paramHeight,  paramThickness,  paramCreatedBy);
         }

         public static bool DeleteShelf(Guid id)
         {
             return shelfDAL.DeleteById(id);
         }

         public static Shelf UpdateShelf(Guid paramId, string paramCode, string paramBarcode, string paramName, string paramDescription, Guid paramWarehouseId,
                                int paramLevels, decimal paramCapacity, decimal paramWeight, decimal paramLength,
                                decimal paramWidth, decimal paramHeight, decimal paramThickness, string paramUpdatedBy)
         {
             return shelfDAL.UpdateById(paramId, paramCode,	paramBarcode, paramName, paramDescription,	paramWarehouseId,
                                paramLevels, paramCapacity, paramWeight, paramLength,
                                paramWidth, paramHeight, paramThickness, paramUpdatedBy);
         }
         #endregion

         #region Unit Info Management
         public static List<Unit> GetUnits()
         {
             return unitDAL.GetAll();
         }

         public static Unit GetUnitById(Guid id)
         {
             return unitDAL.GetById(id);
         }

         public static Unit AddUnit(string paramName, string paramDescription, Guid paramUnitTypeId, string paramCreatedBy)
         {
             return unitDAL.Add(paramName, paramDescription,  paramUnitTypeId, paramCreatedBy);
         }

         public static bool DeleteUnit(Guid id)
         {
             return unitDAL.DeleteById(id);
         }

         public static Unit UpdateUnit(Guid paramId, string paramName, string paramDescription, Guid paramUnitTypeId, string paramUpdatedBy)
         {
             return unitDAL.UpdateById(paramId, paramName,paramDescription, paramUnitTypeId, paramUpdatedBy);
         }
         #endregion

         #region UnitType Info Management
         public static List<UnitType> GetUnitTypes()
         {
             return unitTypeDAL.GetAll();
         }

         public static UnitType GetUnitTypeById(Guid id)
         {
             return unitTypeDAL.GetById(id);
         }

         public UnitType AddUnitType(string paramName, string paramDescriptin, string paramCreatedBy)
         {
             return unitTypeDAL.Add(paramName, paramDescriptin, paramCreatedBy);
         }

         public static bool DeleteUnitType(Guid id)
         {
             return unitTypeDAL.DeleteById(id);
         }

         public static UnitType UpdateUnitType(Guid paramId, string paramName, string paramDescriptin, string paramUpdatedBy)
         {
             return unitTypeDAL.UpdateById(paramId, paramName, paramDescriptin, paramUpdatedBy);
         }
         #endregion

         #region Warehouse Info Management
         public static List<Warehouse> GetWarehouses()
         {
             return warehouseDAL.GetAll();
         }

         public static Warehouse GetWarehouseById(Guid id)
         {
             return warehouseDAL.GetById(id);
         }

         public static Warehouse AddWarehouse(string paramName, string paramDescriptoin, bool paramIsCentral, string paramAddress1, string paramAddress2,
                                    string paramAddress3, string paramPostCode, string paramTel, string paramFax, string paramContactPerson,
                                    Guid paramCoutryId, Guid paramCityId, string paramCreatedBy)
         {
             return warehouseDAL.Add(paramName, paramDescriptoin, paramIsCentral, paramAddress1, paramAddress2,
                                    paramAddress3, paramPostCode, paramTel, paramFax, paramContactPerson,
                                    paramCoutryId,  paramCityId, paramCreatedBy);
         }

         public static bool DeleteWarehouse(Guid id)
         {
             return warehouseDAL.DeleteById(id);
         }

         public static Warehouse UpdateWarehouse(Guid paramId, string paramName, string paramDescriptoin, bool paramIsCentral, string paramAddress1, string paramAddress2,
                                    string paramAddress3, string paramPostCode, string paramTel, string paramFax, string paramContactPerson,
                                    Guid paramCoutryId, Guid paramCityId, string paramUpdatedBy)
         {
             return warehouseDAL.UpdateById(paramId, paramName,	paramDescriptoin, paramIsCentral, paramAddress1, paramAddress2,
                                    paramAddress3, paramPostCode, paramTel, paramFax, paramContactPerson,
                                    paramCoutryId, paramCityId, paramUpdatedBy);
         }
         #endregion

         #region WarehouseArea Info Management
         public static List<WarehouseArea> GetWarehouseAreas()
         {
             return warehouseAreaDAL.GetAll();
         }

         public static WarehouseArea GetWarehouseAreaById(Guid id)
         {
             return warehouseAreaDAL.GetById(id);
         }

         public static WarehouseArea AddWarehouseArea(string paramCode, string paramName, string paramBarcode, Guid paramWarehouseId,
                                        string paramDescription, decimal paramSquareFeet, decimal paramSquareMeter, int paramShelfCapacity,
                                        string paramCreatedBy)
         {
             return warehouseAreaDAL.Add(paramCode, paramName, paramBarcode, paramWarehouseId,
                                        paramDescription, paramSquareFeet, paramSquareMeter, paramShelfCapacity,
                                        paramCreatedBy);
         }

         public static bool DeleteWarehouseArea(Guid id)
         {
             return warehouseAreaDAL.DeleteById(id);
         }

         public static WarehouseArea UpdateWarehouseArea(Guid paramId, string paramCode, string paramName, string paramBarcode, Guid paramWarehouseId,
                                        string paramDescription, decimal paramSquareFeet, decimal paramSquareMeter, int paramShelfCapacity,
                                        string paramUpdatedBy)
         {
             return warehouseAreaDAL.UpdateById(paramId, paramCode,	paramName, paramBarcode, paramWarehouseId,
                                        paramDescription, paramSquareFeet, paramSquareMeter, paramShelfCapacity,
                                        paramUpdatedBy);
         }
         #endregion


        #region WarehouseStock Info Management
         public static WarehouseStock GetWarehouseStock(Guid houseId,Guid productId)
         {
             return stockDAL.GetById(houseId, productId);
         }
         public static List<WarehouseStock> GetWarehouseStocks()
         {
             return stockDAL.GetAll();
         }
        #endregion


         #region Supplier Info Management
         public static List<Supplier> GetSuppliers()
         {
             return supplierDAL.GetAll();
         }

         public static Supplier GetSupplierById(Guid id)
         {
             return supplierDAL.GetById(id);
         }

         public static Supplier AddSupplier(string paramName,string paramAdd1, string paramAdd2, string paramAdd3, string paramCreatedBy)
         {
             return supplierDAL.Add(paramName, paramAdd1, paramAdd2, paramAdd3, paramCreatedBy);
         }

         public static bool DeleteSupplier(Guid id)
         {
             return supplierDAL.DeleteById(id);
         }

         public static Supplier UpdateSupplier(Guid paramId, string paramName, string paramAdd1, string paramAdd2, string paramAdd3, string paramUpdatedBy)
         {
             return supplierDAL.UpdateById(paramId, paramName, paramAdd1, paramAdd2, paramAdd3, paramUpdatedBy);
         }
         #endregion


         public static string GetwarehouseByDOId(Guid id)
         {
             return warehouseDAL.GetwarehouseByDOId(id);
         }


    }
}
